home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / include / sun4.md / a.out.h < prev    next >
C/C++ Source or Header  |  1991-06-11  |  4KB  |  145 lines

  1. /*
  2.  * Copyright (c) 1980 Regents of the University of California.
  3.  * All rights reserved.  The Berkeley software License Agreement
  4.  * specifies the terms and conditions for redistribution.
  5.  *
  6.  *    @(#)a.out.h    5.2 (Berkeley) 4/7/87
  7.  */
  8.  
  9. /*
  10.  * Definitions of the a.out header
  11.  * and magic numbers are shared with
  12.  * the kernel.
  13.  */
  14. #ifndef _AOUT
  15. #define _AOUT
  16.  
  17. #include <sun4.md/sys/exec.h>
  18.  
  19. extern int Aout_PageSize[];
  20.  
  21. /*
  22.  * Macro to tell whether or not the magic number in an a.out file
  23.  * is an illegal one.
  24.  */
  25.  
  26. #define    N_BADMAG(x) \
  27.     (((x).a_magic)!=OMAGIC && \
  28.      ((x).a_magic)!=NMAGIC && \
  29.      ((x).a_magic)!=ZMAGIC && \
  30.      ((x).a_magic)!=SPRITE_ZMAGIC && \
  31.      ((x).a_magic)!=UNIX_ZMAGIC)
  32.  
  33. /*
  34.  * Macros to tell where various pieces of information start in the
  35.  * a.out file.
  36.  */
  37.  
  38. #define N_PAGSIZ(x) (Aout_PageSize[(x).a_machtype])
  39.  
  40. #define N_TXTOFF(x) \
  41.     ((x).a_magic==ZMAGIC ? 0 : sizeof (struct exec))
  42. #define N_SYMOFF(x) \
  43.     (N_TXTOFF(x) + (x).a_text+(x).a_data + (x).a_trsize + (x).a_drsize)
  44. #define    N_STROFF(x) \
  45.     (N_SYMOFF(x) + (x).a_syms)
  46.  
  47. /*
  48.  * Macros to tell where the various segments start in virtual memory,
  49.  * when the process is loaded.
  50.  */
  51. #include <sun4.md/kernel/procMach.h>
  52.  
  53. #define N_TXTADDR(x) PROC_CODE_LOAD_ADDR(*((ProcExecHeader *) &(x)))
  54. #define N_DATADDR(x) PROC_DATA_LOAD_ADDR(*((ProcExecHeader *) &(x)))
  55. #define N_BSSADDR(x) PROC_BSS_LOAD_ADDR(*((ProcExecHeader *) &(x)))
  56.  
  57. /*
  58.  * Sparc relocation types
  59.  */
  60.  
  61. enum reloc_type
  62. {
  63.         RELOC_8,        RELOC_16,       RELOC_32,       /* simplest relocs    */
  64.         RELOC_DISP8,    RELOC_DISP16,   RELOC_DISP32,   /* Disp's (pc-rel)    */
  65.         RELOC_WDISP30,  RELOC_WDISP22,                  /* SR word disp's     */
  66.         RELOC_HI22,     RELOC_22,                       /* SR 22-bit relocs   */
  67.         RELOC_13,       RELOC_LO10,                     /* SR 13&10-bit relocs*/
  68.         RELOC_SFA_BASE, RELOC_SFA_OFF13,                /* SR S.F.A. relocs   */
  69.         RELOC_BASE10,   RELOC_BASE13,   RELOC_BASE22,   /* base_relative pic */
  70.         RELOC_PC10,     RELOC_PC22,                     /* special pc-rel pic*/
  71.         RELOC_JMP_TBL,                                  /* jmp_tbl_rel in pic */
  72.         RELOC_SEGOFF16,                                 /* ShLib offset-in-seg*/
  73.         RELOC_GLOB_DAT, RELOC_JMP_SLOT, RELOC_RELATIVE, /* rtld relocs        */
  74. };
  75.  
  76. /*
  77.  * Format of a relocation datum.
  78.  */
  79.  
  80. struct reloc_info_sparc /* used when header.a_machtype == M_SPARC */
  81. {
  82.         unsigned long int r_address;    /* address which is relocated         */
  83.         unsigned int    r_index   :24;  /* segment index or symbol index      */
  84.         unsigned int    r_extern  : 1;  /* if F, r_index==SEG#; if T, SYM idx */
  85.         int                       : 2;  /* <unused>                           */
  86.         enum reloc_type r_type    : 5;  /* type of relocation to perform      */
  87.         long int        r_addend;       /* addend for relocation value        */
  88. }; 
  89.  
  90.  
  91. #if 0
  92. struct relocation_info {
  93.     int    r_address;    /* address which is relocated */
  94. unsigned int    r_symbolnum:24,    /* local symbol ordinal */
  95.         r_pcrel:1,     /* was relocated pc relative already */
  96.         r_length:2,    /* 0=byte, 1=word, 2=long */
  97.         r_extern:1,    /* does not include value of sym referenced */
  98.         :4;        /* nothing, yet */
  99. };
  100. #endif
  101.  
  102. /*
  103.  * Format of a symbol table entry; this file is included by <a.out.h>
  104.  * and should be used if you aren't interested the a.out header
  105.  * or relocation information.
  106.  */
  107. struct    nlist {
  108.     union {
  109.         char    *n_name;    /* for use when in-core */
  110.         long    n_strx;        /* index into file string table */
  111.     } n_un;
  112. unsigned char    n_type;        /* type flag, i.e. N_TEXT etc; see below */
  113.     char    n_other;    /* unused */
  114.     short    n_desc;        /* see <stab.h> */
  115. unsigned long    n_value;    /* value of this symbol (or sdb offset) */
  116. };
  117. #define    n_hash    n_desc        /* used internally by ld */
  118.  
  119. /*
  120.  * Simple values for n_type.
  121.  */
  122. #define    N_UNDF    0x0        /* undefined */
  123. #define    N_ABS    0x2        /* absolute */
  124. #define    N_TEXT    0x4        /* text */
  125. #define    N_DATA    0x6        /* data */
  126. #define    N_BSS    0x8        /* bss */
  127. #define    N_COMM    0x12        /* common (internal to ld) */
  128. #define    N_FN    0x1e        /* file name symbol */
  129.  
  130. #define    N_EXT    01        /* external bit, or'ed in */
  131. #define    N_TYPE    0x1e        /* mask for all the type bits */
  132.  
  133. /*
  134.  * Sdb entries have some of the N_STAB bits set.
  135.  * These are given in <stab.h>
  136.  */
  137. #define    N_STAB    0xe0        /* if any of these bits set, a SDB entry */
  138.  
  139. /*
  140.  * Format for namelist values.
  141.  */
  142. #define    N_FORMAT    "%08x"
  143.  
  144. #endif /* _AOUT */
  145.